package GUI;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JLabel;

import java.awt.Choice;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;

import Controller.Client;
import Entity.CasualSubscription;
import Entity.Customer;
import Entity.FullSubscription;
import Entity.OneTimeCostumerOrder;
import Entity.Order;
import Entity.Prices;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Date;

/**
 * this is the GUI for the initialize parking lot. the parking lot worker can choose the hight,depth and floor of the parking lot.
 * @author Or Marx
 *
 */
public class InitParkingLotGui extends JPanel{
	JFrame frame;
	JPanel lastPanel;
	public void setLastPanel (JPanel panel)
	{
		this.lastPanel=panel;
	}
	public void setFrame (JFrame frame)
	{
		this.frame=frame;
	}
	
	/**
	 * is the constructor of the GUI. it has listeners for the combo box in order to make the parking lot by the choice of the worker. 
	 */
	public InitParkingLotGui() 
	{
		setLayout(null);
		
		JLabel lblInitializeParkingLot = new JLabel("Initialize Parking lot: "+Client.getParkingLotNameByNumber(Client.getPlWorkerByID(Client.getLoggedIn()).getParkingLotNum()));
		lblInitializeParkingLot.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lblInitializeParkingLot.setBounds(75, 34, 304, 22);
		add(lblInitializeParkingLot);
		
		final Choice choice = new Choice();
		choice.setBounds(52, 139, 55, 22);
		add(choice);
		
		final Choice choice_1 = new Choice();
		choice_1.setBounds(165, 139, 55, 20);
		add(choice_1);
		
		final Choice choice_2 = new Choice();
		choice_2.setBounds(270, 139, 55, 20);
		add(choice_2);
		
		
		JLabel lblLinesInStore = new JLabel("lines in store");
		lblLinesInStore.setBounds(52, 106, 83, 14);
		add(lblLinesInStore);
		
		JLabel lblStores = new JLabel("stores");
		lblStores.setBounds(180, 106, 55, 14);
		add(lblStores);
		
		JLabel lblColsInStore = new JLabel("cols in store");
		lblColsInStore.setBounds(270, 106, 76, 14);
		add(lblColsInStore);
		
		JButton btnInitialize = new JButton("initialize");
		btnInitialize.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Client.getParkingLots_sorted()[Client.getPlWorkerByID(Client.getLoggedIn()).getParkingLotNum()-1].createParkingLot(Integer.valueOf(choice.getSelectedItem()), Integer.valueOf(choice_1.getSelectedItem()), Integer.valueOf(choice_2.getSelectedItem()));
				JOptionPane.showMessageDialog(null,"parking spot initialized succesfuly","parking lot initialize",JOptionPane.INFORMATION_MESSAGE);
				frame.setContentPane((JPanel)lastPanel);
			}
		});
		btnInitialize.setBounds(73, 240, 89, 23);
		add(btnInitialize);
		
		JButton btnCancel = new JButton("cancel");
		btnCancel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				frame.setContentPane((JPanel)lastPanel);
			}
		});
		btnCancel.setBounds(257, 240, 89, 23);
		add(btnCancel);
		
		
		for (int i=1; i<=10; i++)
		{
			choice.add(String.valueOf(i));
			choice_1.add(String.valueOf(i));
			choice_2.add(String.valueOf(i));
		}
	}
}